Basic Image Classifications with Keras

In this article, we go through basic image classification using Multi-layer Perceptron (MLP). For testing the algorithm, we use sklearn digit dataset.

Train and Test sets

One of the efficient methods of splitting a dataset into random train and test subsets is using sklearn.model_selection.train_test_split.

Image Classification

The goal of this approach is to classify the images by focusing on the relationship between nearby pixels. A simple implementation of an image classifier can be performed in Keras using Multi-layer Perceptron (MLP) Image Classification as follows.

Let's define some function by which we can analyze the performance of the modeling.

Model Optimization Plot

Confusion Matrix

The confusion matrix allows for visualization of the performance of an algorithm.

Predictions

For example, we can randomly pick an entry from the correctly predicted labels list

Similarly, from the wrongly predicted labels list


References

  1. scikit-learn digits dataset
  2. Keras developer guides
  3. Multilayer perceptron wikipedia page
  4. Confusion matrix wikipedia page